package com.gwnet.shop.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.gwnet.common.log.annotation.Log;
import com.gwnet.common.log.enums.BusinessType;
import com.gwnet.common.mybatis.core.page.TableDataInfo;
import com.gwnet.common.satoken.utils.LoginHelper;
import com.gwnet.shop.domain.OrderDelivery;
import com.gwnet.shop.service.IOrderDeliveryService;
import com.gwnet.shop.utils.AjaxResult;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 订单发货Controller
 * @author 张万鹏
 * @date 2024-07-21
 */
@RestController
@RequestMapping("/orderdelivery")
public class OrderDeliveryController extends MBaseController
{
    @Resource
    private IOrderDeliveryService orderDeliveryService;

    /**
     * 查询订单发货列表
     */
    @SaCheckPermission("shop:orderdelivery:list")
    @GetMapping("/list")
    public TableDataInfo list(OrderDelivery orderDelivery)
    {
        startPage();
        List<OrderDelivery> list = orderDeliveryService.selectOrderDeliveryList(orderDelivery);
        return getDataTable(list);
    }


    /**
     * 获取订单发货详细信息
     */
    @SaCheckPermission("shop:orderdelivery:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(orderDeliveryService.selectOrderDeliveryById(id));
    }

    /**
     * 新增订单发货
     */
    @SaCheckPermission("shop:orderdelivery:add")
    @Log(title = "订单发货", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderDelivery orderDelivery)
    {
        return toAjax(orderDeliveryService.insertOrderDelivery(orderDelivery));
    }

    /**
     * 修改订单发货
     */
    @SaCheckPermission("shop:orderdelivery:edit")
    @Log(title = "订单发货", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderDelivery orderDelivery)
    {
        return toAjax(orderDeliveryService.updateOrderDelivery(orderDelivery));
    }


    /**
     * 删除订单发货
     */
    @SaCheckPermission("shop:orderdelivery:remove")
    @Log(title = "订单发货", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(orderDeliveryService.deleteOrderDeliveryByIds(ids));
    }
}
